/*
 * @Author: your name
 * @Date: 2021-11-03 17:09:24
 * @LastEditTime: 2021-11-03 17:18:19
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \react-qunaer\src\index\store\reducers.js
 */
import {
  SET_FROM,
  SET_TO,
  SET_IS_CITY_SELECTOR_VISIBLE,
  SET_CURRENT_SELECTING_LEFT_CITY,
  SET_CITY_DATA,
  SET_IS_LOADING_CITY_DATA,
  SET_IS_DATE_SELECTOR_VISIBLE,
  SET_HIGH_SPEED,
  SET_DEPART_DATE,
} from './actions'

// eslint-disable-next-line import/no-anonymous-default-export
export default {
  from(state = '北京', action) {
    const {type, data} = action
    switch (type) {
      case SET_FROM:
        return data
      default:
    }
    return state
  },
  to(state = '上海', action) {
    const {type, data} = action
    switch (type) {
      case SET_TO:
        return data
      default:
    }
    return state
  },
  isCitySelectorVisible(state = false, action) {
    const {type, data} = action
    switch (type) {
      case SET_IS_CITY_SELECTOR_VISIBLE:
        return data
      default:
    }
    return state
  },
  currentSelectingLeftCity(state = false, action) {
    const {type, data} = action
    switch (type) {
      case SET_CURRENT_SELECTING_LEFT_CITY:
        return data
      default:
    }
    return state
  },
  cityData(state = null, action) {
    const { type, data} = action
    switch (type) {
      case SET_CITY_DATA:
        return data
      default:
    }
    return state
  },
  isLoadingCityData(state = false, action) {
    const {type, data} = action
    switch (type) {
      case SET_IS_LOADING_CITY_DATA:
        return data
      default:
    }
    return state
  },
  isDateSelectorVisible(state = false, action) {
    const {type, data} = action
    switch (type) {
      case SET_IS_DATE_SELECTOR_VISIBLE:
        return data
      default:
    }
    return state
  },
  highSpeed(state = false, action) {
    const {type, data} = action
    switch (type) {
      case SET_HIGH_SPEED:
        return data
      default:
    }
    return state
  },
  departDate(state = Date.now(), action) {
    const {type, data} = action
    switch (type) {
      case SET_DEPART_DATE:
        return data
      default:
    }
    return state
  }
}